home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Fades ƒ / Circular fade.c < prev    next >
Text File  |  1994-04-15  |  4KB  |  131 lines

  1. /**********************************************************************\
  2.  
  3. File:        Circular fade.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define CorrectTime 2
  28. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  29. #define theWindowWidth (boundsRect.right-boundsRect.left)
  30.  
  31. pascal short CircularFade(Rect boundsRect, Pattern *thePattern);
  32.  
  33. /* Trace a region from the center to the topleft corner, over <BlockSize> pixels,
  34.    and back to the center.  Fill that in and move the region parameters +BlockSize.
  35.    Repeat for all sides. */
  36.  
  37. pascal short CircularFade(Rect boundsRect, Pattern *thePattern)
  38. {
  39.     RgnHandle    curregion;
  40.     int            cx,cy,lastx,lasty;
  41.     int            BlockSize;
  42.     RgnHandle    boundsRgn,sectrgn;
  43.     
  44.     BlockSize=theWindowWidth/40;
  45.     cx = boundsRect.left + theWindowWidth / 2;
  46.     cy = boundsRect.top + theWindowHeight / 2;
  47.  
  48.     boundsRgn=NewRgn();
  49.     RectRgn(boundsRgn, &boundsRect);
  50.     
  51.     sectrgn=NewRgn();
  52.     curregion=NewRgn();
  53.     lastx=boundsRect.left;
  54.     do                                            /* top quadrant */
  55.     {
  56.         StartTiming();
  57.         SetEmptyRgn(curregion);
  58.         MoveTo(cx,cy);
  59.         OpenRgn();
  60.             LineTo(lastx,boundsRect.top);
  61.             Line(BlockSize,0);
  62.             LineTo(cx,cy);
  63.         CloseRgn(curregion);
  64.         SectRgn(boundsRgn, curregion, sectrgn);
  65.         FillRgn(sectrgn, *thePattern);
  66.         lastx+=BlockSize;
  67.         TimeCorrection(CorrectTime);
  68.     }
  69.     while (lastx<boundsRect.right);
  70.     
  71.     lasty=boundsRect.top;
  72.     do                                            /* right quadrant */
  73.     {
  74.         StartTiming();
  75.         SetEmptyRgn(curregion);
  76.         MoveTo(cx,cy);
  77.         OpenRgn();
  78.             LineTo(boundsRect.right,lasty);
  79.             Line(0,BlockSize);
  80.             LineTo(cx,cy);
  81.         CloseRgn(curregion);
  82.         SectRgn(boundsRgn, curregion, sectrgn);
  83.         FillRgn(sectrgn, *thePattern);
  84.         lasty+=BlockSize;
  85.         TimeCorrection(CorrectTime);
  86.     }
  87.     while (lasty<boundsRect.bottom);
  88.     
  89.     lastx=boundsRect.right;
  90.     do                                            /* bottom quadrant */
  91.     {
  92.         StartTiming();
  93.         SetEmptyRgn(curregion);
  94.         MoveTo(cx,cy);
  95.         OpenRgn();
  96.             LineTo(lastx,boundsRect.bottom);
  97.             Line(-BlockSize, 0);
  98.             LineTo(cx,cy);
  99.         CloseRgn(curregion);
  100.         SectRgn(boundsRgn, curregion, sectrgn);
  101.         FillRgn(sectrgn, *thePattern);
  102.         lastx-=BlockSize;
  103.         TimeCorrection(CorrectTime);
  104.     }
  105.     while (lastx>boundsRect.left-BlockSize);
  106.     
  107.     lasty=boundsRect.bottom;
  108.     do                                            /* left quadrant */
  109.     {
  110.         StartTiming();
  111.         SetEmptyRgn(curregion);
  112.         MoveTo(cx,cy);
  113.         OpenRgn();
  114.             LineTo(boundsRect.left,lasty);
  115.             Line(0, -BlockSize);
  116.             LineTo(cx,cy);
  117.         CloseRgn(curregion);
  118.         SectRgn(boundsRgn, curregion, sectrgn);
  119.         FillRgn(sectrgn, *thePattern);
  120.         lasty-=BlockSize;
  121.         TimeCorrection(CorrectTime);
  122.     }
  123.     while (lasty>boundsRect.top-BlockSize);
  124.     
  125.     DisposeRgn(curregion);
  126.     DisposeRgn(sectrgn);
  127.     DisposeRgn(boundsRgn);
  128.     
  129.     return 0;
  130. }
  131.